<template>
  <div class="check_pass">
    <div class="search">
      <div class="icon">
        <div class="circle"></div>
        <div class="bar"></div>
      </div>
      <div class="search-input">
        <input
          ref="searchInput"
          type="text"
          placeholder="Search..."
          v-model="searchQuery"
        />
      </div>
      <div class="close" @click="$emit('someEvent')">x</div>
    </div>

    <div class="table-container">
      <table>
        <thead>
          <tr>
            <th class="small" @click="sort('position', 'asc')">#</th>
            <th class="medium"></th>
            <th class="large" @click="sort('teamName', 'asc')">Name</th>
            <th class="medium" @click="sort('goalDifference', 'desc')">
              UserNaem
            </th>
            <th class="medium" @click="sort('points', 'asc')">Pas</th>
          </tr>
        </thead>
        <tbody name="fade-list" style="transform: translatey(50px)">
          <tr v-for="team in showList" :key="team.position">
            <td class="small">{{ team.position }}</td>
            <td class="medium"><img :src="team.crestURI" alt="" /></td>
            <td class="large">{{ team.teamName }}</td>
            <td class="medium">
              {{ team.userName }}
            </td>
            <td class="medium">
              <input class="pas" v-model="team.pas" />
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref, onMounted, watch } from 'vue';
const standing = ref([
  {
    teamName: '江西人才集团',
    pas: 'Jxrcjt@1403$$',
    crestURI:
      'https://upload.wikimedia.org/wikipedia/en/e/eb/Manchester_City_FC_badge.svg',
    position: 1,
    userName: 'admin',
    goalsAgainst: 27,
  },
  {
    teamName: '中展 登录账号',
    pas: 'CW081933',
    crestURI:
      'https://upload.wikimedia.org/wikipedia/en/e/eb/Manchester_City_FC_badge.svg',
    position: 2,
    userName: '202302105694',
    goalsAgainst: 27,
  },
  {
    teamName: '阿里云个人使用',
    pas: 'Cwweb141313',
    crestURI:
      'https://upload.wikimedia.org/wikipedia/en/e/eb/Manchester_City_FC_badge.svg',
    position: 3,
    userName: 'cwroot',
    goalsAgainst: 27,
  },
  {
    teamName: 'gmail邮箱',
    pas: 'cwweb141313',
    crestURI:
      'https://upload.wikimedia.org/wikipedia/en/e/eb/Manchester_City_FC_badge.svg',
    position: 4,
    userName: 'csgxyy@gmail.com',
    goalsAgainst: 27,
  },
  {
    teamName: '卧槽云',
    pas: 'cwweb141313',
    crestURI:
      'https://upload.wikimedia.org/wikipedia/en/e/eb/Manchester_City_FC_badge.svg',
    position: 5,
    userName: '1799348030@qq.com',
    goalsAgainst: 27,
  },
  {
    teamName: '工信部',
    pas: 'cwweb141313.',
    crestURI:
      'https://upload.wikimedia.org/wikipedia/en/e/eb/Manchester_City_FC_badge.svg',
    position: 6,
    userName: 'cw141313',
    goalsAgainst: 27,
  },
  {
    teamName: 'apple 开发者',
    pas: 'Cwwb141313.',
    crestURI:
      'https://upload.wikimedia.org/wikipedia/en/e/eb/Manchester_City_FC_badge.svg',
    position: 7,
    userName: '3769159359@qq.com',
    goalsAgainst: 27,
  },
  {
    teamName: '研发云账号密码',
    pas: 'Cwweb141313',
    crestURI:
      'https://upload.wikimedia.org/wikipedia/en/e/eb/Manchester_City_FC_badge.svg',
    position: 8,
    userName: 'srd19398654348',
    goalsAgainst: 27,
  },
  {
    teamName: 'Hbuildx',
    pas: 'Cwweb141313',
    crestURI:
      'https://upload.wikimedia.org/wikipedia/en/e/eb/Manchester_City_FC_badge.svg',
    position: 9,
    userName: '1799348030@qq.com',
    goalsAgainst: 27,
  },
   {
    teamName: '中展数字首页',
    pas: 'https://www.czds-oa.com/login',
    crestURI:
      'https://upload.wikimedia.org/wikipedia/en/e/eb/Manchester_City_FC_badge.svg',
    position: 10,
    userName: '202302105694-CW081933',
    goalsAgainst: 27,
  },
    {
    teamName: '微信开放平台',
    pas: 'cwweb141313',
    crestURI:
      'https://upload.wikimedia.org/wikipedia/en/e/eb/Manchester_City_FC_badge.svg',
    position: 10,
    userName: '1799348030@163.com',
    goalsAgainst: 27,
  },
]);

const showList = ref([]);

const searchQuery = ref('');
const searchInput = ref(null);
onMounted(() => {
  if (showList.value.length == 0) {
    showList.value = standing.value;
  }
});
const reloadList = () => {
  showList.value = standing.value.filter((item) => {
    if (item.teamName.includes(searchQuery.value)) {
      return item;
    }
  });
};
watch(searchQuery, (n, o) => {
  reloadList();
});
</script>
<style lang="less" scoped>
.check_pass {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translate(-50%);
  width: 80%;
  height: 70%;
  box-shadow: 10px 10px 50px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.search {
  box-sizing: border-box;
  padding: 15px 40px;
  display: flex;
  z-index: 1;
  width: 100%;
  background: #38003c;
  position: relative;
  padding-bottom: 15px;
}
.search .icon {
  min-width: 50px;
  height: 50px;
  position: relative;
}
.search .circle {
  position: absolute;
  width: 15px;
  height: 15px;
  border: 3px solid #ffffff;
  border-radius: 50px;
  top: 15px;
  left: 15px;
}
.search .bar {
  width: 3px;
  height: 10px;
  background: #ffffff;
  transform-origin: center top;
  transform: rotateZ(-45deg);
  position: absolute;
  bottom: 7px;
  right: 19px;
  border-radius: 50px;
}
.search-input {
  width: 100%;
  background: #38003c;
  display: flex;
  height: 50px;
}
.search-input input {
  margin: auto;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  padding-left: 1px;
  padding-right: 15px;
  vertical-align: middle;
  white-space: normal;
  background: none;
  line-height: 1;
  border-radius: 50px;
  color: #ffffff;
  font-family: 'helvetica';
  font-size: 1rem;
}
.search-input input:focus {
  outline: 0;
}

.search-input input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.table-container {
  padding: 25px 40px;
  padding-top: 0px;
  background-color: #38003c;
  height: calc(100% - 40px);
  overflow-y: scroll;
  position: relative;
  min-width: 516px;
}
table {
  font-family: 'helvetica';
  font-weight: 600;
  border-collapse: collapse;
  color: #ffffff;
}
thead {
  position: fixed;
  background: #38003c;
  z-index: 10;
}
th {
  color: #00ff85;
  cursor: pointer;
}

th:hover {
  text-decoration: underline;
}

tbody tr:hover {
  background-color: #ffffff;
}

tbody tr:hover td {
  color: #38003c !important;
}
tbody tr:hover td .pas {
  color: #38003c !important;
}

tbody tr {
  padding: 0 5px;
}
td,
th {
  height: 35px;
  text-align: left;
  padding: 0 10px;
  font-size: 24px;
}
td img {
  height: 75%;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.table-container::-webkit-scrollbar-track {
  background-color: #38003c;
}

.table-container::-webkit-scrollbar {
  width: 5px;
  /* 	background-color: #F5F5F5; */
}

.table-container::-webkit-scrollbar-thumb {
  background-color: #ffffff;
}

.fade-list-move {
  transition: transform 0.25s ease;
}

.fade-list-leave-to {
  transition: all 0.5s ease;
  opacity: 0;
}
.pas {
  outline: none;
  cursor: pointer;
  border: none;
  height: 100%;
  width: 100%;
  background-color: transparent;
  color: white;
  font-family: 'helvetica';
  font-weight: 600;
  font-size: 20px;
}
.small {
  min-width: 50px;
}

.medium {
  min-width: 280px;
}

.large {
  min-width: 350px;
}
.close {
  color: white;
  font-size: 40px;
}
</style>
